import React from 'react';
import ReactDOM from 'react-dom';
import { Router } from 'react-router';
import { Route, Switch, Redirect } from 'react-router-dom';
import { createMemoryHistory } from 'history';
import splitComponent from '@/utils/splitComponent';
import Layout from '@/components/Layout';
import './style/index.less';

const history = createMemoryHistory();

function App(params) {
  return (
    <Router history={history}>
      <Layout>
        <Switch>
          <Route
            exact={true}
            path="/home"
            component={splitComponent(() => import('./pages/Home'))}
          />
          <Route
            exact={true}
            path="/download"
            component={splitComponent(() => import('./pages/Download'))}
          />
          <Route
            exact={true}
            path="/manage"
            component={splitComponent(() => import('./pages/Manage'))}
          />
          <Redirect to="/home" />
        </Switch>
      </Layout>
    </Router>
  );
}

export default function render() {
  ReactDOM.render(<App />, document.getElementById('app'));
}
